from PyQt4 import QtCore, QtGui;

class Token(QtGui.QGraphicsObject):
    def __init__(self, qPos=None):
        super(Token, self).__init__();
        self.setPos(qPos);
        self.createToken();
        
    def createToken(self):
        self.qPath = QtGui.QPainterPath();
        nS = 15;
        self.qPath.addEllipse(-nS/2, -nS/2, nS, nS);

    def shape(self):
        return self.qPath;
    
    def boundingRect(self):
        return self.qPath.boundingRect();
        
    def paint(self, painter, option, widget):
        if self.isSelected():
            painter.setPen(QtGui.QPen(QtCore.Qt.blue, 1.5));
        else:
            painter.setPen(QtGui.QPen(QtCore.Qt.red, 0.5));            
        painter.setBrush(QtGui.QBrush(QtCore.Qt.yellow));
        painter.drawEllipse(self.qPath.boundingRect());
